<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>Code Snippet Repository - Add Code Snippet</title>
  <link rel="stylesheet" href="../default.css" />
</head>
<%
UserService userSvc = UserServiceFactory.getUserService();
User currentUser = userSvc.getCurrentUser();
String userName = "";
if (currentUser != null)
{
	userName = currentUser.getNickname();
}
else
{
	String loginUrl = userSvc.createLoginURL("../index.action");
	response.sendRedirect(loginUrl);
}
String logoutUrl = userSvc.createLogoutURL("../index.action");
%>
<body>
    <div id="main">
      <div id="content">
        <div id="login">
          <div id="login-left">Welcome <%= userName %></div>
          <div id="login-right"><a href="<%= logoutUrl%>">Logout</a></div>
        </div>
        <div id="block">
          <h1>Code Snippet Repository</h1>
          <h3>Add Code Snippet</h3>
        </div>
        <div id="strip">
          <a href="/index">Home</a>
        </div>
        <div id="block">
          <s:form action="SaveCodeSnippet.action">
             <s:textfield label="Subject" name="subjectField" size="30"/>
             <s:checkbox name="viewByPublic" label="Available to Entire Community" />
             <s:combobox
                label="Programming Language"
                name="languageField"
                list="{'Ada', 'AWK', 'ASP', 'BOO', 'C/C++', 'C#', 'D', 'DOS BATCH', 'CSS', 'DTD', 'EIFFEL', 'ERLANG', 'F#', 'FORTH', 'FORTRAN', 'HASKEL', 'HTML', 'IDL', 'JAVA', 'JAVASCRIPT', 'LUA', 'MAKEFILE', 'OBJECTIVE-C', 'OBJECTIVE-CAML', 'OOC', 'OPAL', 'PASCAL', 'PERL', 'PHP', 'PROLOG', 'PYTHON', 'RUBY', 'SCHEME', 'SH', 'SQL', 'TCL', 'VALA', 'VB.NET', 'VERILOG', 'VHDL', 'XML', 'XSD', 'XSLT'}"
                headerKey="-1"
                headerValue="--- Please Select ---"
                emptyOption="true" />
             <s:textfield label="Reference URL" name="referenceUrlField" size="30"/>
             <s:textfield label="Keywords" name="keywordsField" size="30"/>
             <s:textfield label="Related Methods" name="relatedMethodsField" size="30"/>
             <s:textarea label="Code Snippet" name="codeSnippetField" rows="8" cols="80"/>
             <s:textarea label="Additional Comments" name="relatedCommentsField" rows="8" cols="80"/>
             <s:submit label="Add Code Snippet"/><s:reset label="Clear"/>
          </s:form>
        </div>
        <div id="strip"></div>
      </div>
    </div>
</body>
</html>